package entity

import (
	"gluenet/modules/manager/server/domain/po"
	"gluenet/modules/manager/server/infra"
	"time"
)

const (
	OrderStateCreated  = "created"
	OrderStateFinished = "finished"
	OrderStateFailed   = "failed"
)

type ScheduleOrder struct {
	infra.Entity
	po.ScheduleOrder
}

func (r *ScheduleOrder) Identity() string {
	return r.ScheduleOrder.OrderID
}

func (r *ScheduleOrder) NewSchedule(instance *Instance) {
	r.ScheduleOrder.OrderID = infra.NewID()
	r.ScheduleOrder.UserID = instance.Instance.UserID
	r.ScheduleOrder.OrderState = OrderStateCreated
	r.ScheduleOrder.InstanceGUID = instance.Instance.GUID
	r.ScheduleOrder.OP = "schedule"
	r.ScheduleOrder.Created = time.Now()
	r.ScheduleOrder.Updated = time.Now()
}
